package com.clqteam.daoimpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.clqteam.dao.ShowrNameDao;
import com.clqteam.model.Role;
import com.clqteam.util.JDBCutil;

/**
 * 
 * @author CLQ
 *
 */
public class ShowrNameDaoImpl implements ShowrNameDao{

	@Override
	public List<Role> getrNameByEmployee() {
		 List<Role> role=new ArrayList<Role>();
			StringBuffer sql = new StringBuffer();
			sql.append(" SELECT s_role.rName,s_role.rId FROM s_role");
			Connection con=JDBCutil.getConnection();
			try {
				 PreparedStatement pst=con.prepareStatement(sql.toString());
				 ResultSet rs=pst.executeQuery();
				 while(rs.next()){
					Role r=new Role();
					r.setrName(rs.getString("rName"));
					r.setrId(rs.getInt("rId"));
					role.add(r);
				 }
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			return role;
	}

}
